package com.lixinxin.benbenlove.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.lixinxin.benbenlove.db.data.NoteData
import kotlinx.coroutines.flow.Flow

@Dao
interface NoteDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(note: NoteData)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert2(note: NoteData)

    @Delete
    suspend fun delete(note: NoteData)

    @Query("SELECT * FROM tb_note")
    fun getAll(): Flow<List<NoteData>>

    @Query("SELECT * FROM tb_note WHERE note_id = :noteId")
    fun getNoteById(noteId: Int): Flow<List<NoteData>>
}